import EventCenter from "../../TFrame/script/helper/EventCenter";
import EventNames from "../EventNames";
import PlayerDataMgr from "../PlayerDataMgr";


const {ccclass, property, requireComponent} = cc._decorator;

@ccclass
@requireComponent(cc.Label)
export default class StarLabel extends cc.Component {

    labelComp: cc.Label = null;

    protected onLoad(): void {
        this.labelComp = this.node.getComponent(cc.Label);
        this.labelComp.string = this.getText();

        EventCenter.on(EventNames.StarCountChange, ()=>{
            this.labelComp.string = this.getText();
        }, this)
    } 


    getText() {
        return 'x' + PlayerDataMgr.getInstance().totalScore;
    }
}
